home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2359 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.3 KB

  1. Path: news.th-darmstadt.de!news
  2. From: Enno Sandner <enno@intellektik.informatik.th-darmstadt.de>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: When to use "->" vs "." when calling Member functions
  5. Date: Wed, 17 Jan 1996 09:38:01 +0100
  6. Organization: Fachbereich Informatik, TH Darmstadt
  7. Message-ID: <30FCB569.41C67EA6@intellektik.informatik.th-darmstadt.de>
  8. References: <4dhea1$6v8@ornews.intel.com>
  9. NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b5 (X11; I; SunOS 4.1.3 sun4m)
  14.  
  15. Thurman Miller wrote:
  16. > I'm confused, so please no harsh remarks :)
  17. > If I've got:
  18. > class Cfoo
  19. > {
  20. >         something * getptr();
  21. >         somethingelse* m_other;
  22. > }
  23. > something * foo::getptr()
  24. > {
  25. >         return m_other;
  26. > }
  27. > Now...if I'm in another class....
  28. >         Cfoo foo;
  29. >         somethingelse* = foo.getptr();
  30. > why doesn't the following work?
  31. >         somethingelse* = foo->getptr();
  32. > I get compile error about no "->" overloaded operator....
  33. > Can someone point out the obvious when I use one notation over
  34. > another?
  35.  
  36. If you want to use 'foo.f' where 'f' is some member of a class,
  37. 'foo' must be an instance or reference to that class. If 'foo'
  38. is a pointer to a class you must use 'foo->f' to access the member 'f'.
  39.  
  40.     Enno
  41.